﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WPay.Application.Interface.OAuth;
using WPay.Domain.Model.DTOs;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace WPay.Web.API.Controllers.OAuth.v1
{
    /// <summary>
    /// TOKEN服务控制器
    /// </summary>
    public class TokenController : BaseController
    {
        private readonly IToken_ApplicationService token_ApplicationService;
        public TokenController(IToken_ApplicationService _token_ApplicationService)
        {
            token_ApplicationService = _token_ApplicationService;
        }

        //客户端提交的数据Content-Type为application/json
        /// <summary>
        /// 获取Token授权
        /// </summary>
        /// <param name="appId">应用ID m1234567</param>
        /// <param name="appSecret">应用开发密钥 7947ff3cbf06647f312e4e6ec5e32943</param>
        /// <returns></returns>
        [AllowAnonymous]
        [HttpPost]
        public JsonResult Get([FromForm] string appId, [FromForm]string appSecret)
        {
            return new JsonResult(this.token_ApplicationService.GetToken(appId, appSecret));
        }
    }
}